﻿using System.Windows;
using System.Windows.Controls;

namespace AutoLoL.Dialogs
{
    /// <summary>
    /// Interaction logic for ModalDialog.xaml
    /// </summary>
    public partial class ConfirmDialog : Window
    {
        public ConfirmDialog(Window owner, string message, string title = "Please confirm", bool isCancelable = true, string defaultText = "Ok", FrameworkElement customContent = null)
        {
            InitializeComponent();
            Owner = owner;
            Title = title;
            MessageTextBox.Text = message;
            OkButton.Content = new TextBlock() { Text = defaultText };
            CancelButton.Visibility = (isCancelable ? System.Windows.Visibility.Visible : System.Windows.Visibility.Collapsed);

            if (isCancelable)
            {
                OkButton.IsDefault = true;
                CancelButton.IsCancel = true;
            }
            else
            {
                OkButton.IsDefault = true;
                OkButton.IsCancel = true;
            }

            if (customContent != null)
            {
                CustomContentStackPanel.Children.Add(customContent);
            }
        }

        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = true;
            Close();
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
            Close();
        }
    }
}
